import 'dart:ffi';

enum FruitEnum { apple, banana,mdefault }

extension ExFruitEnum on FruitEnum {
  String get name {
    switch (this) {
      case FruitEnum.apple:
        return "apple";
      case FruitEnum.banana:
        return "banana";
      default:
        return "default";
    }
  }
}

///字符串匹配枚举
FruitEnum generateFruit(String fruitType){
  if(fruitType == FruitEnum.apple.name){
    return FruitEnum.apple;
  } else if(fruitType == FruitEnum.banana.name){
    return FruitEnum.banana;
  }
  return FruitEnum.mdefault;
}


//扩展list的方法
extension ExList<T> on List<T> {
  //扩展操作符
  List<T> operator -() => reversed.toList();
  //一个链表分割成两个
  List<List<T>> split(int at) => <List<T>>[sublist(0, at), sublist(at)];
}

void main(){
  List a =[1,2,3,4,5,6,7,8];
  List b = -a;
  print(a);
  print(b);
}